package effective.ch03;

import java.awt.*;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2017/1/8 22:02
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2017/1/8 22:02
 */
public class ColorPoint extends Point {
    private final Color color;
    public ColorPoint(int x, int y,Color color) {
        super(x, y);
        this.color = color;
    }

    //@Override
    //public boolean equals(Object obj) {
    //    if(!(obj instanceof ColorPoint))
    //        return false;
    //    return super.equals(obj) && ((ColorPoint)obj).color == color;
    //}


    //@Override
    //public boolean equals(Object obj) {
    //    if(!(obj instanceof Point))
    //        return  false;
    //    if(!(obj instanceof ColorPoint))
    //        return obj.equals(this);
    //    return super.equals(obj) && ((ColorPoint) obj).color == color;
    //}



    public static void main(String[] args) {
        Point p = new Point(1, 2);
        ColorPoint cp = new ColorPoint(1, 2, Color.RED);
        ColorPoint cp2 = new ColorPoint(1, 2, Color.BLUE);
        System.out.println(p.equals(cp));
        System.out.println(p.equals(cp2));
        System.out.println(cp.equals(cp2));
    }
}
